<!DOCTYPE html>
<html lang="en"
	  xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8">
	<title>注册</title>
	<meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<!-- stylesheet css -->
	<link rel="stylesheet" th:href="@{/css/bootstrap.min.css}">
<!--	<link rel="stylesheet" th:href="@{/css/font-awesome.min.css}" >-->
<!--	<link rel="stylesheet" th:href="@{/css/templatemo-blue.css}">-->
	<link rel="stylesheet" th:href="@{/css/diy.css}">
</head>
<body data-spy="scroll" data-target=".navbar-collapse">

<header>
	<div class="container">
		<div class="row">
			<div class="col-md-offset-3 col-md-6">
				<form id="registerForm" name="registerForm" class="form-horizontal" role="form" >
					<span class="tm-title heading">注 册</span>
					<div class="form-group">
						<input type="text" name="nickname" class="form-control" id="nickname" placeholder="手机号">
						<i class="fa fa-user"></i>
					</div>
					<div class="form-group help">
						<input type="password" name="password" class="form-control" id="password" placeholder="密　码">
						<i class="fa fa-lock"></i>
					</div>

					<div class="form-group">
						<button type="button" class="btn btn-default" onclick="doRegister()">注 册</button>
					</div>

				</form>
			</div>
		</div>
	</div>
</header>
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/js/bootstrap.min.js}"></script>
<script th:src="@{/js/main.js}"></script>
<!--md5-->
<script type="text/javascript" th:src="@{/js/md5.min.js}"></script>
<!-- common.js -->
<script type="text/javascript" th:src="@{/js/common.js}"></script>
<!-- layer -->
<script type="text/javascript" th:src="@{/layer/layer.js}"></script>

</body>
<script>
    function doRegister() {
    	var num = 0;
        var inputPass = $("#password").val();
        var salt = g_passsword_salt;
        var str = "" + salt.charAt(0) + salt.charAt(2) + inputPass + salt.charAt(5) + salt.charAt(4);
        var password = md5(str);
        var mobile = $("#nickname").val();
        console.log(mobile+":"+password);
        $.ajax({
            url: "/user/doRegister",
            type: "POST",
            data: {
                mobile: mobile,
                password: password
            },
            success: function (data) {
                layer.closeAll();
                if (data.code == 200) {
                    window.layer.msg("注册成功，为你跳转到登陆页面");
					setTimeout(function(){window.location.href="/login";},1500);
                } else {
                    layer.msg(data.message);
                }
            },
            error: function () {
                layer.closeAll();
            }
        });
    }
</script>
</html>